/**
 * 
 */
package xiaojian.toolkit.ebus.closure;

import org.apache.commons.collections4.Closure;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import xiaojian.toolkit.ebus.EventBus;


/**
 * @author hp
 *
 */
public class ConstantEventDispatchClosure implements Closure {

    private static final Logger logger = 
    	LoggerFactory.getLogger(ConstantEventDispatchClosure.class);
    
    private	EventBus	eventBus;
    
	private	String		constantEvent = null;
	
	/* (non-Javadoc)
	 * @see org.apache.commons.collections.Closure#execute(java.lang.Object)
	 */
	public void execute(Object input) {
		if ( null == input ) {
			return;
		}
		
		if ( logger.isDebugEnabled() ) {
			logger.debug("fire event [" + constantEvent + "] <--> " + input);
		}
		eventBus.fireEvent(constantEvent, input);
	}


	public EventBus getEventBus() {
		return eventBus;
	}


	public void setEventBus(EventBus eventBus) {
		this.eventBus = eventBus;
	}


	/**
	 * @return the constantEvent
	 */
	public String getConstantEvent() {
		return constantEvent;
	}


	/**
	 * @param constantEvent the constantEvent to set
	 */
	public void setConstantEvent(String constantEvent) {
		this.constantEvent = constantEvent;
	}

}
